import request from "../util/request.ts";
import type { User } from "./type/model.ts"

export const fetchUserList = async (): Promise<any> => {
    return await request.get(`/user`);
}
export const fetchUserPage = async (currentPage: number, pageSize: number, user: User, during:[]): Promise<any> => {
    return await request.get(`/user/page`, {
        params: {
            currentPage,
            pageSize,
            user: JSON.stringify(user),
            during: during?during.join(','):[]
        }
    });
}
export const postUser = async (user:User): Promise<any> => await request.post("/user", user)

export const putUser = async (user:User): Promise<any> => await request.put("/user", user)

export const delUser = async (userId:number): Promise<any> => await request.delete(`/user/${userId}`)

export const batchDelUser = async (userIds:[]): Promise<any> => await request.delete(`/user/batch/delete`, {
    params: {
        userIds: userIds.join(',')
    }
})



export const  exportUserData = async () => await request.get("/user/export",{responseType: "blob"})


export const fetchUserInfo = async (): Promise<any> => await request.get("/user/info")

export const fetchUserById = async (userId: Number): Promise<any> => {
    return await request.get(`/user/${userId}`)
}